<!--
 * @description  : 案件-涉案物品核价表
 * @descriptionDetail: 案件-涉案物品核价表
 * @copyright    : 浙江烟草
 * @author       : dw
 * @create       : 2022-10-09 22:21:21
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
      <view class="nav-right-icon" @click="printOrDown(state.canEdit)">
        {{ state.canEdit?'预览':'打印' }}
      </view>
    </theme-navbar>
    <!-- #endif -->
    <!-- #ifdef H5-WECHAT || H5-EMP -->
    <fab-button :content="state.canEdit?fContent:fContents" @fabtrigger="fabtrigger" />
    <!-- #endif -->
    <!-- 表单开始 -->
    <view class="main-content">
      <view style="width: calc(100% + 30px);">
        <form-section title="涉案物品核价表"></form-section>
      </view>

      <u-form :label-position="labelPosition" :model="queryRecordForm" :error-type="errorType" :rules="rules" class="form-content" ref="uForm">
        <u-form-item
            label="核价单位"
            prop="orgName"
            :required="isRequired"
            :label-position="labelPosition"
            :label-width="labelWidth"
        >
          <u-input
              :disabled="!state.canEdit"
              placeholder="请输入核价单位"
              v-model="queryRecordForm.orgName"
          />
        </u-form-item>

        <u-form-item
            label="立案编号"
            prop="caseCode"
            :required="isRequired"
            :label-position="labelPosition"
            :label-width="labelWidth"
        >
          <u-input
              :disabled="!state.canEdit"
              placeholder="请输入立案编号"
              v-model="queryRecordForm.caseCode"
          />
        </u-form-item>


        <u-form-item
            label="当事人"
            :label-width="labelWidth"
            :required="true"
            prop="party"
            right-icon="arrow-right"
        >
          <u-input placeholder="请输入" input-align="right" :disabled="!state.canEdit" v-model="queryRecordForm.party" @click="()=>{if(state.canEdit) partySelectShow = true}" />
        </u-form-item>

        <u-form-item
            label="立案时间"
            :required="isRequired"
            prop="regDate"
            :label-position="labelPosition"
            right-icon="arrow-right"
            ref="docDate"
        >
          <u-input
              placeholder="请输入立案时间"
              :disabled="!state.canEdit"
              :custom-style="pointerStyle"
              :clearable="false"
              v-model="queryRecordForm.regDate"
              @click="()=>{if(state.canEdit) clickDateBtn('regDate')}"
          />
        </u-form-item>

        <u-form-item prop="handlePerson" ref="handlePersonRef">
          <view class="person-info">
            <view class="p-title">
              <view class="doc-sub-required">
                *
              </view>
              <view class="doc-sub-title">
                经办人
              </view>
              <view class="uicon-sty" @click="docSub(state.canEdit, '02')">
                <u-icon name="plus-circle" :color="$theme.u_type_primary" size="40"></u-icon>
              </view>
            </view>
            <u-input placeholder="请输入" type="textarea" height="100" :auto-height="true" :disabled="!state.canEdit" v-model="queryRecordForm.handlePerson" />
          </view>
        </u-form-item>

        <u-form-item
            label="文书日期"
            :required="isRequired"
            prop="docDate"
            :label-position="labelPosition"
            right-icon="arrow-right"
            ref="docDate"
        >
          <u-input
              placeholder="请输入文书日期"
              :disabled="!state.canEdit"
              :custom-style="pointerStyle"
              :clearable="false"
              v-model="queryRecordForm.docDate"
              @click="()=>{if(state.canEdit) clickDateBtn('docDate')}"
          />
        </u-form-item>
        <u-form-item label="" :label-position="labelPosition">
          <view style="width: 100%" v-if="priceMakeUuid">
            <show-goods-info
                v-if="psParam.caseUuid && priceMakeUuid"
                :caseUuid="psParam.caseUuid"
                :dataFromInit="getGoodsPriceMakeDtl"
                ref="goodInfoRef"
                :hasDel="state.canEdit"
                :canEdit="state.canEdit"
            >
            </show-goods-info>
          </view>
          <view style="width: 100%" v-else>
            <show-goods-info
                v-if="psParam.caseUuid"
                :caseUuid="psParam.caseUuid"
                :dataFromInit="getGoodsPriceMakeDtl"
                ref="goodInfoRef"
                :hasDel="state.canEdit"
            >
            </show-goods-info>
          </view>
        </u-form-item>

        <u-form-item
            label="备注（核价依据）"
            prop="remark"
            :bordebottom="false"
            label-width="auto"
            label-position="top"
        >
          <u-input style="margin-bottom: 20rpx" type="textarea" height="35" :auto-height="true" placeholder="告知事项" :disabled="!state.canEdit" v-model="queryRecordForm.remark" />
        </u-form-item>
      </u-form>
    </view>
    <!-- 底部按钮开始 -->
    <view class="submit-btns btn-other-cls" v-if="state.canEdit">
      <u-button plain class="u-btn" type="primary" @click="submitBtn('save')">
        保存
      </u-button>
      <u-button class="u-btn" type="primary" @click="submitBtn('submit')">
        提交
      </u-button>
    </view>

    <!-- 底部按钮结束 -->
    <!-- 人员选择 -->
    <u-popup mode="bottom" height="80%" v-model="personSelectShow">
      <person-selection :params="psParam" @choose="handlerChoosePerson"></person-selection>
    </u-popup>

    <u-picker mode="time" :params="paramsDate" v-model="regDate" @confirm="changeDate('regDate',$event)">
    </u-picker>

    <u-picker mode="time" :params="paramsDate" v-model="docDate" @confirm="changeDate('docDate',$event)">
    </u-picker>

    <!-- 当事人   -->
    <u-popup mode="bottom" height="80%" v-model="partySelectShow">
      <select-party-component :params="partyParams" :isCheckBox="false" @choose="handlerChooseParty"></select-party-component>
    </u-popup>

    <u-popup mode="bottom" height="80%" v-model="showFieldTpl">
      <doc-form-content-tep
          :params="fieldParam"
          formName="queryRecordForm"
          :fieldkey="fieldKey"
          :canEdit="state.canEdit"
          @choice="choiceFieldTpl"
      ></doc-form-content-tep>
    </u-popup>
    <!-- 下拉选择用 -->
    <dic-choice
        :keyWord="dicKeyWords"
        :currentSelect="dicCurrentSelect"
        v-model="dicShow"
        @confirm="selectDicConfirm"
    ></dic-choice>

  </view>
</template>

<script>
import caseCommon from '../caseCommonMixin.js';
import officeService from '@/service/case/office.service.js';
import PersonSelection from '@/pages/case/components/personSelection.vue';
import {
  IDENTITY_TYPE
} from '@/common/common_enum.js';
import DicChoice from '@/components/dic_choice.vue';
import DicInput from '@/components/dic_input.vue';
import moment from 'moment';
import GoodsListCom from '../components/goodsListComponent.vue';
import caseService from '@/service/case/case.service.js';
import zjCommonService from '@/service/common/common.service';
import SelectPartyComponent from '../components/selectPartyComponent.vue';
import DocFormContentTep from '../components/docFormContentTemplate.vue';
import FormSection from '@/components/form-section.vue';
import {
  CASE_DOC_NAME_PATH
} from '@/service/case/mapping/index.js';
import {
  L_BSC_IDCARD_TYPE
} from '@/service/intelligence/mapping/enum.js';
import fabButton from '@/components/uni-fab.vue';
import commonService from "@/service/common/common.service";
import ShowDocPriceAuditGoodsInfo from "@/pages/case/components/showDocPriceAuditGoodsInfo.vue";

export default {
  components: {
    'show-goods-info': ShowDocPriceAuditGoodsInfo,
    PersonSelection,
    GoodsListCom,
    SelectPartyComponent,
    FormSection,
    DocFormContentTep,
    DicInput,
    DicChoice,
    fabButton
  },
  mixins: [caseCommon],
  data() {
    return {
      moment,
      IDENTITY_TYPE,
      paramsDate: {
        year: true,
        month: true,
        day: true,
        hour: false,
        minute: false,
        second: false,
        timestamp: false,
      },
      border: false,
      errorType: ['border-bottom', 'message'],
      isRequired: true,
      labelWidth: '220',
      labelPosition: 'top',
      maxLength: 9999,
      isShowAskS: false,
      isShowAskE: false,
      isCanClick: false, // 是否可点击承办人按钮
      employeeLst: [], // 选择人员数据
      perFlag: '', // 选择人员类型 询问人or记录人
      caseParam: {}, // 上个页面传过来的参数
      queryRecordForm: {},
      doc: {},
      personSelectShow: false,
      psParam: {},
      goodsData: {}, // 物品数据
      baseInfo: {},
      params: {},
      orginalCaseClueList: [],
      // dic_select 是否显示
      dicShow: false,
      // dic 关键字
      dicKeyWords: '',
      // dic 当前选择项
      dicCurrentSelect: '',
      dicType: '',
      rules: {
        orgName: [{
          required: true,
          message: '请输入核价单位',
          trigger: ['change', 'blur'],
        }, ],
        caseCode: [{
          required: true,
          message: '请输入立案编号',
          trigger: ['change', 'blur'],
        }, ],
        party: [{
          required: true,
          message: '当事人不能为空',
          trigger: ['change', 'blur'],
        }, ],
        regDate: [{
          required: true,
          message: '立案时间不能为空',
          trigger: ['change', 'blur'],
        }, ],
        handlePerson: [{
          required: true,
          message: '经办人不能为空',
          trigger: ['change', 'blur'],
        }, ],
        arriveEndTime: [{
          required: true,
          message: '询问时间不能为空',
          trigger: ['change', 'blur'],
        }, ],
        handlingAddr: [{
          required: true,
          message: '询问地点不能为空',
          trigger: ['change', 'blur'],
        }, ],
        connectPhone: [{
          required: true,
          message: '联系电话不能为空',
          trigger: ['change', 'blur'],
        }, ],
        undertaker: [{
          required: true,
          message: '承办人（签名）不能为空',
          trigger: ['change', 'blur'],
        }, ],
        docDate: [{
          required: true,
          message: '文书日期不能为空',
          trigger: ['change', 'blur'],
        }, ],
        serviceStyle: [{
          required: true,
          message: '送达方式不能为空',
          trigger: ['change', 'blur'],
        }, ],
        serviceAddr: [{
          required: true,
          message: '送达地点不能为空',
          trigger: ['change', 'blur'],
        }, ]
      },
      btnType: '',
      isReadBoolean: [],
      partySelectShow: false,
      partyNames: '', // 当事人名称
      partyList: [], // 当事人列表
      partyParams: {}, // 传给当事人选择页面的参数
      ifborder: false,
      fContent: [{
        iconPath: require('@/static/oview.png'),
        selectedIconPath: require('@/static/oview.png'),
        text: '预览',
        active: false,
      }],
      fContents: [{
        iconPath: require('@/static/dy.png'),
        selectedIconPath: require('@/static/dy.png'),
        text: '打印',
        active: false,
      }],
      // h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx start
      pointerStyle: {
        marginRight: "5px",
        pointerEvents: "none !important"
      },
      // h5端部分浏览器input设置disabled后点击事件失效 2023-10-27 fsx end
      isTransCase: false,
      userType: '',
      arriveEndTime: false,
      docDate: false,
      regDate: false,
      goodsList: [],
      priceMakeUuid: ''
    };
  },
  watch: {
  },
  onReady() {
    this.$refs.uForm.setRules(this.rules);
  },
  onLoad(preParams) {
    this.caseParam = this.getRouteParam();
    console.log('caseParam', this.caseParam)
    this.psParam.caseUuid = this.caseParam.caseUuid;
    caseService
        .getCaseInfoById({
          caseUuid: this.psParam.caseUuid,
        })
        .then((res) => {
          this.$modal.hideLoading();
          this.baseInfo = res.bean || {};
          this.getDefaultCaseClue();
        })
        .catch((res) => {
          this.$modal.hideLoading();
          this.$u.toast(res.msg);
        });
  },
  mounted() {
    this.docStep((docInfo) => {
      this.doc = docInfo;
      this.setRightBtns();
    });
    this.initDocData();
  },
  methods: {
    getGoodsPriceMakeDtl() {
      return new Promise((resolve, reject) => {
        if (this.fromInDoc) {
          resolve({
            noPage: 1,
            data: this.goodsList,
          });
          return;
        }
        caseService
            .getGoodsPriceMakeDtl({
              caseUuid: this.caseParam.caseUuid,
              priceMakeUuid: this.priceMakeUuid
            })
            .then((res) => {
              let resData = this.$u.deepClone(res.data)
              resData.forEach((ele) => {
                console.log('amt', ele)
                if (!ele.price) {
                  ele.price = 0
                }
                if (!ele.qty) {
                  ele.qty = 0
                }
              })

              this.goodsList = !res.success ? [] : [...resData, ];
              resolve({
                noPage: 1,
                data: this.goodsList,
              });
            })
            .catch((e) => {
              this.goodsList = [];
              resolve({
                noPage: 1,
                data: this.goodsList,
              });
            });
      });
    },

    getDefaultCaseClue() {
      caseService
          .casePropertyList()
          .then((res) => {
            if (!res.success) {
              return;
            }
            if (res.data && res.data.length > 0) {
              if (this.baseInfo.casePropertyRelList && this.baseInfo.casePropertyRelList.length > 0) {
                this.orginalCaseClueList = [];
                for (let i = 0; i < this.baseInfo.casePropertyRelList.length; i++) {
                  let op = this.baseInfo.casePropertyRelList[i];
                  for (let j = 0; j < res.data.length; j++) {
                    if (res.data[j].casepropUuid == op.casepropUuid) {
                      let opx = res.data[j];
                      this.objMerge(opx, op);
                      this.orginalCaseClueList.push(opx);
                      this.params.orginalCaseClueList = this.orginalCaseClueList;
                      break;
                    }
                  }
                }
              }
            }
          })
          .catch((err) => {
            console.log('查询失败:' + err);
          });
    },
    docSub(flag, userType) {
      if (flag) {
        this.userType = userType;
        this.personSelectShow = true;
        this.psParam = {
          min: 2,
          caseUuid: this.psParam.caseUuid,
        };
      }
    },
    dicSelectOpen(type, keyWords) {
      if (type == this.dicType) {
        if (this.dicKeyWords == keyWords && this.dicShow) {
          return true;
        }
        return false;
      }
    },
    showDic(key, cur, type) {
      if (!this.state.canEdit) return;
      if (this.dicShow) return;
      this.dicKeyWords = key;
      this.dicCurrentSelect = cur;
      this.dicShow = true;
      this.dicType = type;
    },
    addAskPsn() {
      if (this.state.canEdit) {
        this.partySelectShow = true;
      }
    },
    selectDicConfirm(e) {
      if (this.dicKeyWords == this.$u.dic.DIC_KEYS.BSC_SERVICE_TYPE) {
        this.queryRecordForm.serviceStyleName = e[0].label;
        this.queryRecordForm.serviceStyle = e[0].extra.bcbCode;
      }
    },
    initDocData() {
      this.$u.loading('加载中...');
      officeService
          .docFields(this.caseParam.docUuid, true)
          .then((docConfigs) => {
            if (docConfigs.success) {
              this.docFields = [...docConfigs.data];
              let parms = {
                id: this.caseParam.id,
                docUuid: this.caseParam.docUuid,
                bizUuid: this.caseParam.bizUuid,
              };
              // 获取询问笔录数据
              officeService
                  .getDocPriceAudit(parms)
                  .then((res) => {

                    this.$u.hideLoading();
                    let [tiInfo, rs] = [{}, {}];
                    if (res.success && res.data.length === 2) {
                      tiInfo = res.data[0];
                      rs = res.data[1];
                      Object.keys(tiInfo).forEach((key) => {
                        rs[key] = tiInfo[key];
                      });
                    } else {
                      rs = res.data[0];
                    }

                    this.queryRecordForm = rs;

                    this.priceMakeUuid = rs.priceMakeUuid

                    if (!this.queryRecordForm.regDate) {
                      this.queryRecordForm.regDate = rs.docDate
                    }

                    this.getPartyInfoList();
                  })
                  .catch((er) => {
                    console.log(er);
                    this.$u.hideLoading();
                    this.$u.toast(er);
                  });
            } else {
              this.$u.toast(docConfigs.msg);
            }
          })
          .catch((er) => {
            console.log(er);
            this.$u.hideLoading();
            this.$u.toast(er);
          });
    },
    // 获取审批通过的先保书
    getDoodsRegs() {
      officeService.getDoodsRegs({
        caseUuid: this.queryRecordForm.bizUuid,
      }).then((res) => {
        if (res.success) {
          this.handleGoodsSelect(res.data);
        }
      }).catch((err) => {
        this.$u.toast(err);
      });
    },
    checkboxChange(e) {
      this.isReadBoolean = e;
      if (this.isReadBoolean) {
        this.queryRecordForm.isRead = 1;
      }
    },
    // 获取当事人list（单选）
    getPartyInfoList() {
      caseService
          .getPartyInfoList(this.caseParam.bizUuid)
          .then((res) => {
            if (!res.success) return;
            let names = [];
            let uuids = [];
            this.partyList = res.data.length > 0 ? res.data : [];
            this.partyList.forEach((itm) => {
              names.push(itm.partyName);
              uuids.push(itm.partyUuid);
              if (this.queryRecordForm.partyUuids === itm.partyUuid) {
                itm.check = true;
              }
            });
            this.partyParams = {
              list: this.partyList,
              selUsersStr: this.queryRecordForm.partyUuids,
            };
          })
          .catch((err) => {
            this.partyList = [];
            console.log(err);
          });
    },
    // 选择当事人回调事件
    handlerChooseParty(e) {
      this.partySelectShow = false;
      this.queryRecordForm.byAskPsn = e.partyNames;
      this.partyParams.selUsersStr = e.partyUuids;
      this.queryRecordForm.partyUuids = e.partyUuids;
      this.queryRecordForm.byAskNation = e.list[0].nation; // 民族
      this.queryRecordForm.byAskSex = e.list[0].partyType; // 性别
      this.queryRecordForm.byAskPhone = e.list[0].phone; // 联系电话
      this.queryRecordForm.byAskIdType = e.list[0].idCardType; // 证件类型
      this.queryRecordForm.byAskIdNo = e.list[0].idCard; // 证件号码
      this.queryRecordForm.byAskAddr = e.list[0].busiAddr; // 经营地址
      this.queryRecordForm.byAskHomeAddr = e.list[0].idCardAddr; // 证件地址
      this.queryRecordForm.byAskAge = e.list[0].age; // 年龄
      this.$forceUpdate();
    },
    // 查询案件物品信息表
    getGoodsList() {
      officeService.caseGoodsPunishList(this.caseParam.caseUuid).then(res => {
        if (res.success) {
          let num = 0;
          let amt = 0.00;
          let sellNum = 0;
          let sellAmt = 0.00;
          res.data && res.data.forEach(g => {
            num += g.qty;
            amt += g.amt;
            sellNum += (g.illegalQty || 0);
            sellAmt += (g.illegalAmt || 0);
          });
          this.goodsData = {
            list: res.data,
            goodsUnitNum: parseFloat(num.toFixed(2)),
            goodsAmt: parseFloat(amt.toFixed(2)),
            sellNum: parseFloat(sellNum.toFixed(2)),
            sellAmt: parseFloat(sellAmt.toFixed(2)),
          }
        }
      });

    },
    // 设置右侧标题
    setRightBtns() {
      // #ifdef H5-DINGDING
      this.$deviceApi.setRight(this.state.canEdit ? '预览' : '打印', () => {
        this.printOrDown(this.state.canEdit);
        this.setRightBtns();
      }, true, true);
      // #endif
    },
    fabtrigger(btn) {
      if (btn.index == 0) {
        this.printOrDown(this.state.canEdit);
      }
    },
    // 打印/预览
    printOrDown(flag) {
      if (flag) {
        // 调接口预览
        this.submitDocInfo('preview');
      } else {
        this.downloadFile(this.doc.pdfFileId);
      }
    },
    downloadFile(fileId, titleName, isDownload) {
      let pdfIds = fileId;
      if (!pdfIds) {
        this.$u.toast('没有文书');
        return;
      }
      this.setRouteParam({
        fileId: pdfIds,
        fileName: titleName,
        isDownload: isDownload,
        isSign: CASE_DOC_NAME_PATH[this.doc?.configIns?.docCode]?.isSign,
      });
      this.$u.route('pages/commonPage/printerComponent');
    },
    clickDateBtn(type) {
      this[type] = true;
    },
    // 表单验证
    validForm(type) {
      let basicValid = false;
      this.btnType = type;
      this.$refs.uForm.validate((valid) => {
        if (valid) {
          if (!this.queryRecordForm.partyUuids) {
            this.$u.toast('请选择当事人!');
            return;
          }
          basicValid = true;
          console.log('表单验证通过');
        } else {
          basicValid = false;
          console.log('表单验证失败');
        }
      });
      return basicValid;
    },
    submitBtn(type) {
      // 点击提交、保存按钮
      let flag = this.validForm(type);
      if (flag) {
        if (type == 'submit') {
          this.$modal.confirm('完成后不可修改，请确认是否填写完整准确无误？', () => {
            this.submitDocInfo(type);
          });
        } else {
          this.submitDocInfo(type);
        }
      }
    },
    submitDocInfo(type) {
      // 保存/提交
      let {
        id,
        docUuid,
        titemUuid
      } = this.caseParam;
      this.queryRecordForm.caseUuid = this.psParam.caseUuid;
      this.$u.loading('数据保存中...');


      let queryRecordForm = this.$u.deepClone(this.queryRecordForm);

      let delArr = [
          'totalQty', 'totalAmt', 'isActive', 'creator', 'createTime',
          'modifier', 'modifyTime', 'ownDeptUuid', 'ownOrgUuid'
      ]
      if (queryRecordForm) {
        delArr.forEach(ele => {
          delete queryRecordForm[ele]
        })
      }
      console.log('goods', this.goodsList)

      let goodsList = this.$u.deepClone(this.goodsList)
      goodsList.forEach((ele) => {
        ele.amt = this.priceInfo(ele)
      })

      queryRecordForm.goods = this.goodsList

      console.log('queryRecordForm', queryRecordForm)

      officeService.saveDocPriceAudit(queryRecordForm, docUuid, titemUuid, id, this.caseParam.type).then((res) => {
        this.$u.hideLoading();
        if (res.success) {
          this.queryRecordForm = {
            ...this.queryRecordForm,
            ...res.bean,
          };
          try {
            if (!this.doc) this.doc = res.data[0];
          } catch (e) {
            console.log(e);
          }
          if (type == 'submit') {
            this.$u.loading('数据提交中...');
            let submitQueryRecordForm = this.$u.deepClone(this.queryRecordForm);
            if (submitQueryRecordForm) {
              delArr.forEach(ele => {
                delete submitQueryRecordForm[ele]
              })
            }
            submitQueryRecordForm.goods = this.goodsList
            officeService.submitDocPriceAudit(submitQueryRecordForm, docUuid, titemUuid, id, this.caseParam.type).then((res) => {
              this.$u.hideLoading();
              this.$u.toast(res.msg);
              this.saveBehaviorLog(1, this.caseParam, this.doc);
              if (res.success) {
                this.backPrev({
                  paramKey: 'offiList',
                  param: {
                    caseUuid: this.caseParam.bizUuid,
                    caseCode: this.caseParam.caseCode,
                    caseType: this.caseParam.caseType,
                  },
                });
              }
            });
          } else if (type == 'preview') {
            this.$u.loading('生成PDF中...');
            officeService.buildLocalPunish('/survey/doc-inquiry-notice', this.doc.docInsUuid).then((pdfId) => {
              this.$u.hideLoading();
              if (pdfId.success) {
                this.downloadFile(pdfId.bean, '预览', false);
              } else {
                this.$u.toast(pdfId.msg);
              }
            });
          } else {
            this.saveBehaviorLog(0, this.caseParam, this.doc);
            this.$u.toast(res.msg);
          }
        } else {
          this.$u.hideLoading();
          this.$u.toast(res.msg);
        }
      });
    },
    // 添加询问人和记录人
    addUndertaker(flag) {
      if (flag == 'aPer') {
        this.psParam.min = 2;
        delete this.psParam.max;
      } else {
        this.psParam.max = 1;
        delete this.psParam.min;
      }
      this.perFlag = flag;
      this.personSelectShow = true;
    },

    priceInfo(d) {
      try {
        return (d.retailPrice * d.qty).toFixed(1)
      } catch (err) {
        console.log(err)
      }
      return '';
    },

    // 选择执行人（询问人、记录人）
    handlerChoosePerson(e) {
      this.personSelectShow = false;
      this.employeeLst = [...e];
      let tIds = [];
      let tNames = [];
      this.employeeLst.forEach((el) => {
        tIds.push(el.personUuid);
        tNames.push(`${el.personName}(${el.inspectionCertNo})`);
      });
      if (this.userType === '01') {
        this.queryRecordForm['handlingPerson'] = tNames.join(',');
      } else if (this.userType === '02') {
        this.queryRecordForm['undertakerUuids'] = tIds.join(',');
        this.queryRecordForm['undertaker'] = tNames.join(',');
      }
    },
    changeDate(type, e) {
      this.queryRecordForm[type] = this.$u.date(e.timestamp, 'yyyy年mm月dd日');
    },
    getWidth() {
      let w = this.$u.sys().windowWidth - 32 + 'px';
      return w;
    },
    updateBackState(param) {
      if (param.caseSelectionData) {
        // 案由选择回调
        let arr = [];
        let arrIds = [];
        param.caseSelectionData.map((itm) => {
          itm.caseUuid = this.queryRecordForm.caseUuid;
          arr.push(itm.caseProperty);
          arrIds.push(itm.casepropUuid);
        });
        this.isTransCase =
            arrIds.includes("1") ||
            arrIds.includes("2") ||
            arrIds.includes("3") ||
            arrIds.includes("27");
        this.queryRecordForm.casePropertyRelList = param.caseSelectionData;
        this.$set(this.queryRecordForm, 'causeOfAction', arr.join("、"));
        this.getLegalPunishData(param.caseSelectionData);
      }
    },
    getLegalPunishData(arr) {
      let punishArgume = [];
      let legalArgume = [];
      for (let i = 0; i < arr.length; i++) {
        if (arr[i].propertySmokeType == "01") {
          // 专卖案由
          punishArgume.push(arr[i].punishItem || "");
          legalArgume.push(arr[i].legalItem || "");
        } else {
          // 电子烟案由
          let xp = arr[i].smokeIllegalUuid
              ? arr[i].smokeIllegalUuid.split(",")
              : [];
          let eilist = arr[i].electricSmokeIllegalList.filter((it) => {
            return xp.includes(it.smokeIllegalUuid);
          });
          for (let j = 0; j < eilist.length; j++) {
            punishArgume.push(eilist[j].legalBasic || "");
            legalArgume.push(eilist[j].qualitativeBasic || "");
          }
        }
      }
      this.baseInfo.punishArgume = punishArgume.join(",");
      this.baseInfo.legalArgume = legalArgume.join(",");
    },
    choiceCaseOfAction(canEdit) {
      if (!canEdit) {
        return false
      }
      this.setRouteParam(this.queryRecordForm.casePropertyRelList || []);
      this.$u.route({
        url: "/pages/case/components/casePropertySelection",
        params: {
          handleProc: this.queryRecordForm.handleProc, // 获取案件类型
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
@import '../case_common.scss';

.page {
  padding: 0;
}
</style>
